const buffer_1 = Buffer.alloc(10) // 创建一个10字节大小的buffer
console.info(buffer_1) // <Buffer 00 00 00 00 00 00 00 00 00 00>: 00占据8位, 每一个占据4位

const buffer_2 = Buffer.allocUnsafe(10) // 创建一个10字节大小的buffer
console.info(buffer_2) // <Buffer 53 6c 69 63 65 02 10 51 00 00>

// 3类参数: 字符串,数组, buffer
const buffer_3 = Buffer.from('1') // 默认是UTF-8编码
console.info(buffer_3) // <Buffer 31>: 1作为utf-8编码,然后转成16进制

const buffer_4 = Buffer.from('中') // 一个汉字占据3个字节
console.info(buffer_4) // <Buffer e4 b8 ad>

const buffer_5 = Buffer.from([1, 2, 3])
console.info(buffer_5) // <Buffer 01 02 03>

const buffer_6 = Buffer.from([1, 2, '中'])
console.info(buffer_6) // <Buffer 01 02 00>

const b_1 = Buffer.from('中')
console.info(b_1.toString()) // 中

const b_2 = Buffer.alloc(3)
const buffer_8 = Buffer.from(b_2)
console.info(b_2) // <Buffer 00 00 00>
console.info(buffer_8) // <Buffer 00 00 00>
// 是否会影响: 不会影响数据, 创建新的空间去操作,执行的是断链操作
b_2[0] = 1
console.info(b_2) // <Buffer 01 00 00>
console.info(buffer_8) // <Buffer 00 00 00>
